package com.atelier.plugin.pjavafx;


import com.intellij.diff.DiffContext;
import com.intellij.diff.DiffManagerEx;
import com.intellij.diff.contents.FileContentImpl;
import com.intellij.diff.requests.SimpleDiffRequest;
import com.intellij.diff.tools.holders.TextEditorHolder;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.EditorFactory;
import com.intellij.openapi.editor.ex.EditorEx;
import com.intellij.openapi.editor.impl.EditorFactoryImpl;
import com.intellij.openapi.fileEditor.impl.text.TextEditorImpl;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.wm.ToolWindowFactory;
import com.intellij.ui.EditorTextField;
import org.jetbrains.annotations.NotNull;

import java.io.File;


/**
 * @author tangrufei
 * @date 2023-06-05 13:56
 */
public class MyTestToolWindows implements ToolWindowFactory {
    /**
     * @param project
     * @param toolWindow
     */
    @Override
    public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
        //文件树测试
        // FileSystemTree fileSystemTree = FileSystemTreeFactory.SERVICE.getInstance()
        //        .createFileSystemTree
        //                (project,
        //                        new FileChooserDescriptor
        //                                (true,
        //                                        true, true, true, true, true));
        //
        // JTree tree = fileSystemTree.getTree();
        // Content test = ContentFactory.SERVICE.getInstance().createContent(tree, "test", false);
        //toolWindow.getContentManager().addContent(test);

        //文本编辑器   可以选择文件类型
        //EditorFactory editorFactory = EditorFactory.getInstance();
        //Document document = editorFactory.createDocument("123");
        // Editor editor = EditorFactory.getInstance().createEditor(document);
        //EditorTextField.setupTextFieldEditor((EditorEx) editor);
        //
        //Content test = ContentFactory.SERVICE.getInstance().createContent(editor.getComponent(), "test", false);
        //toolWindow.getContentManager().addContent(test);
        // File file = new File("D:\\code8\\Atelier\\src\\test\\java\\com\\sjhy\\plugin\\diffTest\\DiffTest.java");
        //File file1 = new File("D:\\code8\\Atelier\\src\\test\\java\\com\\sjhy\\plugin\\MinTest.java");
        // VirtualFile fileByIoFile = LocalFileSystem.getInstance().findFileByIoFile(file);
        //VirtualFile fileByIoFile1 = LocalFileSystem.getInstance().findFileByIoFile(file1);
        // FileContentImpl fileContent = new FileContentImpl(project, fileByIoFile);
        //FileContentImpl fileContent1 = new FileContentImpl(project, fileByIoFile1);
        // SimpleDiffRequest simpleDiffRequest = new SimpleDiffRequest("文件对比", fileContent, fileContent1, "file1", "file2");
        //DiffManagerEx.getInstance().showDiff(project, simpleDiffRequest);
        //文本编辑器   可以选择文件类型
        //EditorFactory editorFactory = EditorFactory.getInstance();
        //Document document = editorFactory.createDocument("123");
        // Editor editor = EditorFactory.getInstance().createEditor(document);
        //EditorTextField.setupTextFieldEditor((EditorEx) editor);
        //TextEditorImpl.getDocumentLanguage(editor)
    }
}
